﻿using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SmartCity.Shared;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;

namespace MetroManagement
{
    /// <summary>
    /// 乘车卡控制器
    /// </summary>
    [Authorize]
    [RemoteService]
    [Area("metroManagement")]
    [Route("api/metroManagement/cards")]
    public class CardController : AbpController, ICardAppService
    {
        private readonly ICardAppService _cardAppService;

        public CardController(
            ICardAppService cardAppService)
        {
            _cardAppService = cardAppService;
        }

        // 获取
        [HttpGet]
        [Route("")]
        public Task<ResultResponse<CardDto>> GetAsync()
        {
            return _cardAppService.GetAsync();
        }

        // 添加
        [HttpPost]
        [Route("")]
        public Task<ActionResponse> CreateAsync(CreateCardDto input)
        {
            return _cardAppService.CreateAsync(input);
        }

        // 删除
        [HttpDelete]
        [Route("{id}")]
        public Task<ActionResponse> DeleteAsync(int id)
        {
            return _cardAppService.DeleteAsync(id);
        }
    }
}